Exploratory Plots for 2017-2018 Acoustic/Fish Data
Purpose To explore the Acoustic data gathered in 2017 and 2018 to expose important trends between sites, diurnal patterns, fish abundance, lunar phase, and coral reef acoustics.
Combined Model All variables are matched to the files that were used for Fish call counts (3:00, 9:00, 15:00, 21:00)
Red is the Mean Line
Blue is the Median Line
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Stats for Mid Frequency SPL
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 100.2 103.4 104.7 105.8 107.7 119.3
Variance of MF
## [1] 11.87399
Stats for High Frequency SPL
## Min. 1st Qu. Median Mean 3rd Qu. Max.
## 100.4 114.5 117.2 117.1 119.2 129.1
Variance of HF
## [1] 11.96909
ACI histogram
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Running basic regressions linking the explanatory to the response at their lowest levels and combined to see how different sites/ hours change the regression - SPL
Linear Model outputs below each
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = Snap.HF17)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.8309 -1.9842 0.2062 1.8451 13.3944
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.053e+02 6.541e-01 160.99 <2e-16 ***
## Snaps 7.227e-03 4.475e-04 16.15 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.807 on 10163 degrees of freedom
## Multiple R-squared: 0.02502, Adjusted R-squared: 0.02493
## F-statistic: 260.8 on 1 and 10163 DF, p-value: < 2.2e-16
2017 Snap data, snaps significant.
When you break it down by site, site 32 has the opposite relationship with high frequency and snaps.
2017 Snap/HF SPL Site Breakdown
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s17s5)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.0817 -2.1540 0.4371 1.9805 7.0937
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 87.830664 1.873329 46.88 <2e-16 ***
## Snaps 0.018381 0.001277 14.39 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.483 on 2101 degrees of freedom
## Multiple R-squared: 0.08971, Adjusted R-squared: 0.08928
## F-statistic: 207.1 on 1 and 2101 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s17s8)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.3374 -1.3945 0.1363 1.4230 9.4265
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.185e+01 1.270e+00 56.59 <2e-16 ***
## Snaps 3.314e-02 9.084e-04 36.48 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.117 on 1831 degrees of freedom
## Multiple R-squared: 0.4209, Adjusted R-squared: 0.4206
## F-statistic: 1331 on 1 and 1831 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s17s35)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.9213 -1.7565 -0.0424 1.6512 10.3407
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 71.282701 1.451690 49.10 <2e-16 ***
## Snaps 0.029598 0.000995 29.75 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.573 on 2205 degrees of freedom
## Multiple R-squared: 0.2864, Adjusted R-squared: 0.2861
## F-statistic: 884.9 on 1 and 2205 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s17s40)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.1902 -1.2312 0.0344 1.2186 9.3897
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.644e+01 1.044e+00 73.19 <2e-16 ***
## Snaps 2.679e-02 7.062e-04 37.93 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.736 on 1862 degrees of freedom
## Multiple R-squared: 0.4359, Adjusted R-squared: 0.4356
## F-statistic: 1439 on 1 and 1862 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s17s32)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.936 -1.084 0.114 1.063 7.102
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 137.43721 0.89844 152.97 <2e-16 ***
## Snaps -0.01414 0.00060 -23.56 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.532 on 2156 degrees of freedom
## Multiple R-squared: 0.2047, Adjusted R-squared: 0.2044
## F-statistic: 555 on 1 and 2156 DF, p-value: < 2.2e-16
2018 Snap/HF SPL
Removing outliers
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = Snap.HF18)
##
## Residuals:
## Min 1Q Median 3Q Max
## -8.6746 -2.0071 -0.0087 2.3005 12.6859
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 81.468599 1.919126 42.45 <2e-16 ***
## Snaps 0.025921 0.001315 19.71 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.072 on 1453 degrees of freedom
## Multiple R-squared: 0.211, Adjusted R-squared: 0.2105
## F-statistic: 388.7 on 1 and 1453 DF, p-value: < 2.2e-16
2018 Snap data with outliers removed. Snaps significant.
When split by sight, site 32 has a flat relationship.
2018 Snap/HF SPL Site Breakdown
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s18s5)
##
## Residuals:
## Min 1Q Median 3Q Max
## -5.9245 -1.5844 0.1253 1.6517 5.3652
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 60.225493 4.141984 14.54 <2e-16 ***
## Snaps 0.038216 0.002823 13.54 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.238 on 289 degrees of freedom
## Multiple R-squared: 0.388, Adjusted R-squared: 0.3859
## F-statistic: 183.2 on 1 and 289 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s18s8)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.7323 -1.3490 -0.0334 1.4302 4.1632
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 68.048894 2.745679 24.78 <2e-16 ***
## Snaps 0.035631 0.001889 18.87 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.849 on 289 degrees of freedom
## Multiple R-squared: 0.5519, Adjusted R-squared: 0.5504
## F-statistic: 356 on 1 and 289 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s18s35)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.9232 -1.1784 -0.1059 1.0416 7.5440
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 83.11812 1.96366 42.33 <2e-16 ***
## Snaps 0.02652 0.00133 19.94 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.739 on 289 degrees of freedom
## Multiple R-squared: 0.5791, Adjusted R-squared: 0.5776
## F-statistic: 397.6 on 1 and 289 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s18s40)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.4914 -1.3764 -0.1106 1.2747 6.8204
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 68.686141 2.640335 26.01 <2e-16 ***
## Snaps 0.033362 0.001816 18.38 <2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.869 on 289 degrees of freedom
## Multiple R-squared: 0.5388, Adjusted R-squared: 0.5372
## F-statistic: 337.7 on 1 and 289 DF, p-value: < 2.2e-16
##
## Call:
## lm(formula = SPL_HF ~ Snaps, data = s18s32)
##
## Residuals:
## Min 1Q Median 3Q Max
## -3.6331 -1.9735 0.2795 1.8090 4.4940
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.213e+02 3.090e+00 39.250 <2e-16 ***
## Snaps -2.742e-04 2.136e-03 -0.128 0.898
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.074 on 289 degrees of freedom
## Multiple R-squared: 5.699e-05, Adjusted R-squared: -0.003403
## F-statistic: 0.01647 on 1 and 289 DF, p-value: 0.898
Mid Frequency - SPL
##
## Call:
## lm(formula = SPL_Midrange ~ Tot_Knocks, data = AC.DF1)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.2088 -2.1924 -0.7869 1.6962 11.9299
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.045e+02 3.773e-01 277.047 < 2e-16 ***
## Tot_Knocks 1.801e-02 4.252e-03 4.237 3.54e-05 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 3.302 on 189 degrees of freedom
## Multiple R-squared: 0.08674, Adjusted R-squared: 0.08191
## F-statistic: 17.95 on 1 and 189 DF, p-value: 3.538e-05
Mid Frequency - ACI
##
## Call:
## glm(formula = ACI_Midrange ~ Tot_Knocks + Year, family = "Gamma",
## data = AC.DF1)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.24710 -0.14537 -0.07297 0.11790 0.40777
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.746e-05 3.758e-07 46.459 <2e-16 ***
## Tot_Knocks -8.617e-09 3.462e-09 -2.489 0.0137 *
## Year18 2.779e-07 4.078e-07 0.682 0.4964
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02745441)
##
## Null deviance: 4.9867 on 190 degrees of freedom
## Residual deviance: 4.8131 on 188 degrees of freedom
## AIC: 4038.2
##
## Number of Fisher Scoring iterations: 4
##
## Call:
## glm(formula = ACI_Midrange ~ Num_L_calls + Year, family = "Gamma",
## data = AC.DF1)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.19561 -0.15304 -0.06392 0.11642 0.42225
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.690e-05 3.382e-07 49.964 <2e-16 ***
## Num_L_calls -4.017e-09 2.953e-08 -0.136 0.892
## Year18 2.304e-07 4.140e-07 0.557 0.579
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02823657)
##
## Null deviance: 4.9867 on 190 degrees of freedom
## Residual deviance: 4.9772 on 188 degrees of freedom
## AIC: 4044.6
##
## Number of Fisher Scoring iterations: 4
##
## Call:
## glm(formula = ACI_Midrange ~ Num_Herbivory + Year, family = "Gamma",
## data = AC.DF1)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.22182 -0.15000 -0.06905 0.11317 0.42714
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.697e-05 3.019e-07 56.198 <2e-16 ***
## Num_Herbivory -2.940e-08 2.290e-08 -1.284 0.201
## Year18 2.350e-07 4.112e-07 0.571 0.568
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02795665)
##
## Null deviance: 4.9867 on 190 degrees of freedom
## Residual deviance: 4.9338 on 188 degrees of freedom
## AIC: 4042.9
##
## Number of Fisher Scoring iterations: 4
##
## Call:
## glm(formula = ACI_Midrange ~ Tot_Knocks + Site + Year + Hour,
## family = "Gamma", data = AC.DF1)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.23464 -0.14810 -0.02786 0.09402 0.40045
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.687e-05 5.893e-07 28.620 < 2e-16 ***
## Tot_Knocks -6.857e-09 4.115e-09 -1.666 0.09738 .
## Site35 -3.948e-07 6.308e-07 -0.626 0.53219
## Site40 1.842e-06 6.744e-07 2.731 0.00694 **
## Site5 -1.827e-07 7.031e-07 -0.260 0.79525
## Site8 -2.771e-07 6.134e-07 -0.452 0.65206
## Year18 2.542e-07 3.925e-07 0.648 0.51800
## Hour21 6.213e-07 5.771e-07 1.077 0.28311
## Hour3 6.336e-07 5.689e-07 1.114 0.26689
## Hour9 1.735e-07 5.654e-07 0.307 0.75935
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02532824)
##
## Null deviance: 4.9867 on 190 degrees of freedom
## Residual deviance: 4.3779 on 181 degrees of freedom
## AIC: 4034
##
## Number of Fisher Scoring iterations: 4
Breakdown by Site - SPL
Breakdown by Site - ACI
Breakdown by Hour - SPL
Breakdown by Hour - ACI
3 AM, long calls don’t seem to explain a great deal of the relationship at any site
9 AM, long calls don’t seem to explain the relationship at any site
3 PM, long calls don’t seem to explain the relationship
9 PM, long calls don’t seem to explain the relationship
3 AM, Extremely low herbivory at all sites. No relationship
Again, extremely low herbivory, no relationship.
Higher herbivory. Seems like there is a relationship at site 40, 8, and 35.
Higher herbivory here as well, although there is no positive relationship at any site.
Summary Knocks significantly explained SPLMF at sites 35 and 32 and at 9AM.
Acoustics Breakdown All acoustic metrics (SPL and ACI) are broken down into 2 frequency bands: High Frequency (Frequencies between 1 kHz - 22 kHz) and Mid Frequency (Frequencies between 160 Hz and 1 kHz)
Note 2017 had a 10 minute duty cycle with 5 minutes recording while 2018 had a 15 minute duty cycle with 5 minutes recording, so the number of files averages differs between years
Total Deployment Plots
Preliminary Models Looking into the relationships between biogenic sounds (Knocks/Calls and Snaps) and their frequency spectra (MF SPL/HF SPL) respectively.
shapiro.test(AC.DF1$SPL_Midrange)
##
## Shapiro-Wilk normality test
##
## data: AC.DF1$SPL_Midrange
## W = 0.92679, p-value = 3.406e-08
qqnorm(AC.DF1$SPL_Midrange)
#ks.test(SPLHF.long$SPL_HF, "pnorm", mean=mean(SPLHF.long$SPL_HF), sd=sd(SPLHF.long$SPL_HF))
#ks.test(SPLMF.long$SPL_MF, "pnorm", mean=mean(SPLMF.long$SPL_MF), sd=sd(SPLMF.long$SPL_MF))
ggplot(data = Snap.HF, aes(Snap.HF$SPL_HF)) + geom_histogram() + ggtitle("HF SPL distribution")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(data = AC.DF1, aes(AC.DF1$ACI_Midrange)) + geom_histogram() + ggtitle("MF ACI distribution")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
ggplot(data = AC.DF1, aes(AC.DF1$ACI_HF)) + geom_histogram() + ggtitle("HF ACI distribution")
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
gamma_test(AC.DF1$ACI_Midrange)
##
## Test of fit for the Gamma distribution
##
## data: AC.DF1$ACI_Midrange
## V = 4.3336, p-value = 0.002182
gamma_test(AC.DF1$ACI_HF)
##
## Test of fit for the Gamma distribution
##
## data: AC.DF1$ACI_HF
## V = 4.9011, p-value = 0.0005291
gamma_test(Snap.HF$SPL_HF)
##
## Test of fit for the Gamma distribution
##
## data: Snap.HF$SPL_HF
## V = 7.8948, p-value = 2.372e-08
Don’t seem to have a normal distribution here… Working on testing different distributions. Can’t find what the p-values indicate for these gamma tests
Maximal Model with Bill
fit.m <- lm(SPL_Midrange ~(Tot_Knocks + Num_Herbivory + Num_L_calls)*(Site + Hour) + Year, data = AC.DF1Co)
summary(fit.m)
##
## Call:
## lm(formula = SPL_Midrange ~ (Tot_Knocks + Num_Herbivory + Num_L_calls) *
## (Site + Hour) + Year, data = AC.DF1Co)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.2170 -1.2622 -0.1569 1.1008 5.9507
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.040e+02 1.039e+00 100.154 < 2e-16 ***
## Tot_Knocks 6.742e-03 1.513e-02 0.446 0.656421
## Num_Herbivory 2.019e-01 3.082e-01 0.655 0.513320
## Num_L_calls -4.731e-02 1.181e-01 -0.401 0.689255
## Site35 9.601e-01 1.166e+00 0.823 0.411629
## Site40 -2.755e+00 1.070e+00 -2.574 0.010960 *
## Site5 -5.481e-01 1.095e+00 -0.501 0.617374
## Site8 -1.808e+00 1.038e+00 -1.743 0.083340 .
## Hour21 8.820e-01 5.437e-01 1.622 0.106767
## Hour3 -2.264e+00 2.092e+00 -1.082 0.280983
## Hour9 2.618e+00 2.096e+00 1.249 0.213552
## Year18 3.925e+00 3.196e-01 12.282 < 2e-16 ***
## Tot_Knocks:Site35 -1.458e-02 1.432e-02 -1.018 0.310289
## Tot_Knocks:Site40 1.099e-02 1.726e-02 0.636 0.525394
## Tot_Knocks:Site5 -1.831e-02 1.408e-02 -1.301 0.195163
## Tot_Knocks:Site8 -1.516e-02 1.522e-02 -0.996 0.320693
## Tot_Knocks:Hour21 8.699e-03 1.092e-02 0.797 0.426879
## Tot_Knocks:Hour3 1.184e-02 1.102e-02 1.074 0.284454
## Tot_Knocks:Hour9 4.361e-02 1.171e-02 3.723 0.000273 ***
## Num_Herbivory:Site35 -1.447e-01 3.092e-01 -0.468 0.640479
## Num_Herbivory:Site40 -5.393e-01 3.150e-01 -1.712 0.088813 .
## Num_Herbivory:Site5 -2.400e-01 3.076e-01 -0.780 0.436461
## Num_Herbivory:Site8 -7.112e-02 3.085e-01 -0.231 0.817956
## Num_Herbivory:Hour21 -6.096e-04 8.470e-02 -0.007 0.994267
## Num_Herbivory:Hour3 -7.106e-01 6.836e-01 -1.040 0.300117
## Num_Herbivory:Hour9 5.260e-01 7.094e-01 0.741 0.459511
## Num_L_calls:Site35 2.410e-01 1.910e-01 1.262 0.208822
## Num_L_calls:Site40 1.828e-01 1.078e-01 1.696 0.091819 .
## Num_L_calls:Site5 -7.132e-02 1.396e-01 -0.511 0.610178
## Num_L_calls:Site8 4.688e-02 1.028e-01 0.456 0.648863
## Num_L_calls:Hour21 8.163e-02 9.719e-02 0.840 0.402248
## Num_L_calls:Hour3 3.101e-02 1.165e-01 0.266 0.790544
## Num_L_calls:Hour9 -2.675e-01 1.351e-01 -1.980 0.049427 *
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.041 on 158 degrees of freedom
## Multiple R-squared: 0.7084, Adjusted R-squared: 0.6493
## F-statistic: 12 on 32 and 158 DF, p-value: < 2.2e-16
stepAIC(fit.m)
## Start: AIC=302.21
## SPL_Midrange ~ (Tot_Knocks + Num_Herbivory + Num_L_calls) * (Site +
## Hour) + Year
##
## Df Sum of Sq RSS AIC
## - Num_Herbivory:Hour 3 6.83 664.69 298.19
## - Tot_Knocks:Site 4 24.83 682.68 301.29
## <none> 657.86 302.21
## - Num_L_calls:Site 4 36.35 694.20 304.48
## - Num_L_calls:Hour 3 41.50 699.35 307.90
## - Num_Herbivory:Site 4 79.04 736.90 315.88
## - Tot_Knocks:Hour 3 92.30 750.16 321.29
## - Year 1 628.11 1285.96 428.24
##
## Step: AIC=298.19
## SPL_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site +
## Hour + Year + Tot_Knocks:Site + Tot_Knocks:Hour + Num_Herbivory:Site +
## Num_L_calls:Site + Num_L_calls:Hour
##
## Df Sum of Sq RSS AIC
## - Tot_Knocks:Site 4 24.85 689.54 297.20
## <none> 664.69 298.19
## - Num_L_calls:Site 4 35.64 700.33 300.16
## - Num_L_calls:Hour 3 40.27 704.96 303.42
## - Tot_Knocks:Hour 3 88.49 753.18 316.06
## - Num_Herbivory:Site 4 96.88 761.56 316.17
## - Year 1 647.13 1311.81 426.04
##
## Step: AIC=297.2
## SPL_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site +
## Hour + Year + Tot_Knocks:Hour + Num_Herbivory:Site + Num_L_calls:Site +
## Num_L_calls:Hour
##
## Df Sum of Sq RSS AIC
## <none> 689.54 297.20
## - Num_L_calls:Site 4 36.89 726.43 299.15
## - Num_L_calls:Hour 3 50.99 740.52 304.82
## - Num_Herbivory:Site 4 101.98 791.52 315.54
## - Tot_Knocks:Hour 3 101.17 790.70 317.34
## - Year 1 655.66 1345.20 422.84
##
## Call:
## lm(formula = SPL_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls +
## Site + Hour + Year + Tot_Knocks:Hour + Num_Herbivory:Site +
## Num_L_calls:Site + Num_L_calls:Hour, data = AC.DF1Co)
##
## Coefficients:
## (Intercept) Tot_Knocks Num_Herbivory
## 103.883544 -0.004243 0.281592
## Num_L_calls Site35 Site40
## -0.026390 1.211723 -3.008499
## Site5 Site8 Hour21
## -0.733301 -1.642642 0.779976
## Hour3 Hour9 Year18
## -0.199326 1.006530 3.904610
## Tot_Knocks:Hour21 Tot_Knocks:Hour3 Tot_Knocks:Hour9
## 0.009165 0.009517 0.040037
## Num_Herbivory:Site35 Num_Herbivory:Site40 Num_Herbivory:Site5
## -0.223915 -0.607692 -0.328665
## Num_Herbivory:Site8 Num_L_calls:Site35 Num_L_calls:Site40
## -0.148352 0.223663 0.137930
## Num_L_calls:Site5 Num_L_calls:Site8 Num_L_calls:Hour21
## -0.132447 0.004349 0.109991
## Num_L_calls:Hour3 Num_L_calls:Hour9
## 0.050565 -0.257516
Next is the best model from AIC stepwise model selection
#SPL_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site + Hour + Year + Tot_Knocks:Site + Tot_Knocks:Hour + Num_Herbivory:Site + Num_L_calls:Site + Num_L_calls:Hour
fit.m2 <- lm(SPL_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site + Hour + Year + Tot_Knocks:Site + Tot_Knocks:Hour + Num_Herbivory:Site + Num_L_calls:Site + Num_L_calls:Hour, data = AC.DF1Co)
Anova(fit.m2, type=3)
## Anova Table (Type III tests)
##
## Response: SPL_Midrange
## Sum Sq Df F value Pr(>F)
## (Intercept) 44532 1 10786.5010 < 2.2e-16 ***
## Tot_Knocks 1 1 0.1624 0.6874574
## Num_Herbivory 4 1 0.9933 0.3204412
## Num_L_calls 1 1 0.1826 0.6697040
## Site 120 4 7.2699 2.087e-05 ***
## Hour 42 3 3.3839 0.0196605 *
## Year 647 1 156.7463 < 2.2e-16 ***
## Tot_Knocks:Site 25 4 1.5048 0.2032243
## Tot_Knocks:Hour 88 3 7.1449 0.0001554 ***
## Num_Herbivory:Site 97 4 5.8663 0.0001968 ***
## Num_L_calls:Site 36 4 2.1582 0.0760730 .
## Num_L_calls:Hour 40 3 3.2514 0.0233376 *
## Residuals 665 161
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(fit.m2)
##
## Call:
## lm(formula = SPL_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls +
## Site + Hour + Year + Tot_Knocks:Site + Tot_Knocks:Hour +
## Num_Herbivory:Site + Num_L_calls:Site + Num_L_calls:Hour,
## data = AC.DF1Co)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.2174 -1.2322 -0.1251 1.0980 5.9555
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 104.206794 1.003358 103.858 < 2e-16 ***
## Tot_Knocks 0.005885 0.014603 0.403 0.687457
## Num_Herbivory 0.278351 0.279293 0.997 0.320441
## Num_L_calls -0.050139 0.117328 -0.427 0.669704
## Site35 0.766076 1.120805 0.684 0.495270
## Site40 -2.936460 1.041347 -2.820 0.005408 **
## Site5 -0.742531 1.046012 -0.710 0.478813
## Site8 -2.085095 0.990076 -2.106 0.036756 *
## Hour21 0.879295 0.538575 1.633 0.104501
## Hour3 -0.168172 0.562300 -0.299 0.765265
## Hour9 1.120116 0.608855 1.840 0.067653 .
## Year18 3.942663 0.314913 12.520 < 2e-16 ***
## Tot_Knocks:Site35 -0.013232 0.014091 -0.939 0.349122
## Tot_Knocks:Site40 0.011545 0.017084 0.676 0.500151
## Tot_Knocks:Site5 -0.017482 0.013708 -1.275 0.204032
## Tot_Knocks:Site8 -0.015266 0.014960 -1.020 0.309036
## Tot_Knocks:Hour21 0.008873 0.010204 0.869 0.385874
## Tot_Knocks:Hour3 0.012101 0.010872 1.113 0.267341
## Tot_Knocks:Hour9 0.042694 0.011519 3.706 0.000289 ***
## Num_Herbivory:Site35 -0.221091 0.281598 -0.785 0.433530
## Num_Herbivory:Site40 -0.611817 0.298717 -2.048 0.042169 *
## Num_Herbivory:Site5 -0.317416 0.282805 -1.122 0.263369
## Num_Herbivory:Site8 -0.147308 0.280869 -0.524 0.600671
## Num_L_calls:Site35 0.247525 0.189782 1.304 0.194006
## Num_L_calls:Site40 0.183437 0.106859 1.717 0.087970 .
## Num_L_calls:Site5 -0.069899 0.138445 -0.505 0.614327
## Num_L_calls:Site8 0.053260 0.101700 0.524 0.601206
## Num_L_calls:Hour21 0.080441 0.096709 0.832 0.406763
## Num_L_calls:Hour3 0.044625 0.115290 0.387 0.699218
## Num_L_calls:Hour9 -0.258808 0.133308 -1.941 0.053953 .
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.032 on 161 degrees of freedom
## Multiple R-squared: 0.7054, Adjusted R-squared: 0.6523
## F-statistic: 13.29 on 29 and 161 DF, p-value: < 2.2e-16
plot(fit.m2)
## NULL
## NULL
Maximal model following Bill’s method
fit.a <- glm(ACI_Midrange ~(Tot_Knocks + Num_Herbivory + Num_L_calls)*(Site + Hour) + Year, data = AC.DF1Co, family = "Gamma")
summary(fit.a)
##
## Call:
## glm(formula = ACI_Midrange ~ (Tot_Knocks + Num_Herbivory + Num_L_calls) *
## (Site + Hour) + Year, family = "Gamma", data = AC.DF1Co)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.24879 -0.12333 -0.02497 0.08025 0.36994
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.690e-05 1.444e-06 11.699 <2e-16 ***
## Tot_Knocks -2.546e-08 1.928e-08 -1.321 0.188
## Num_Herbivory 3.467e-07 4.468e-07 0.776 0.439
## Num_L_calls -3.403e-08 1.565e-07 -0.217 0.828
## Site35 -1.184e-06 1.608e-06 -0.736 0.463
## Site40 1.624e-06 1.531e-06 1.061 0.290
## Site5 -1.438e-06 1.512e-06 -0.952 0.343
## Site8 -5.345e-07 1.453e-06 -0.368 0.713
## Hour21 6.913e-07 7.114e-07 0.972 0.333
## Hour3 -1.930e-06 2.549e-06 -0.757 0.450
## Hour9 3.315e-06 3.230e-06 1.026 0.306
## Year18 3.223e-07 4.236e-07 0.761 0.448
## Tot_Knocks:Site35 1.090e-08 1.827e-08 0.597 0.551
## Tot_Knocks:Site40 2.652e-08 2.402e-08 1.104 0.271
## Tot_Knocks:Site5 2.536e-08 1.802e-08 1.407 0.161
## Tot_Knocks:Site8 2.288e-08 1.972e-08 1.160 0.248
## Tot_Knocks:Hour21 6.822e-09 1.391e-08 0.490 0.625
## Tot_Knocks:Hour3 -8.492e-10 1.403e-08 -0.061 0.952
## Tot_Knocks:Hour9 6.244e-09 1.483e-08 0.421 0.674
## Num_Herbivory:Site35 -2.623e-07 4.484e-07 -0.585 0.559
## Num_Herbivory:Site40 -3.463e-07 4.595e-07 -0.754 0.452
## Num_Herbivory:Site5 -3.652e-07 4.459e-07 -0.819 0.414
## Num_Herbivory:Site8 -3.946e-07 4.468e-07 -0.883 0.379
## Num_Herbivory:Hour21 -1.418e-07 1.063e-07 -1.335 0.184
## Num_Herbivory:Hour3 -8.192e-07 8.323e-07 -0.984 0.326
## Num_Herbivory:Hour9 1.189e-06 1.088e-06 1.093 0.276
## Num_L_calls:Site35 1.946e-08 2.478e-07 0.079 0.938
## Num_L_calls:Site40 6.352e-08 1.454e-07 0.437 0.663
## Num_L_calls:Site5 -4.761e-08 1.803e-07 -0.264 0.792
## Num_L_calls:Site8 1.097e-09 1.343e-07 0.008 0.993
## Num_L_calls:Hour21 3.364e-09 1.307e-07 0.026 0.979
## Num_L_calls:Hour3 -1.778e-07 1.564e-07 -1.137 0.257
## Num_L_calls:Hour9 -1.595e-07 1.741e-07 -0.916 0.361
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02551326)
##
## Null deviance: 4.9867 on 190 degrees of freedom
## Residual deviance: 3.8459 on 158 degrees of freedom
## AIC: 4055.2
##
## Number of Fisher Scoring iterations: 4
stepAIC(fit.a)
## Start: AIC=4055.17
## ACI_Midrange ~ (Tot_Knocks + Num_Herbivory + Num_L_calls) * (Site +
## Hour) + Year
##
## Df Deviance AIC
## - Num_L_calls:Site 4 3.8643 4047.9
## - Tot_Knocks:Hour 3 3.8658 4049.9
## - Tot_Knocks:Site 4 3.9294 4050.4
## - Num_L_calls:Hour 3 3.9306 4052.5
## - Num_Herbivory:Site 4 3.9975 4053.1
## - Num_Herbivory:Hour 3 3.9531 4053.4
## - Year 1 3.8606 4053.7
## <none> 3.8459 4055.2
##
## Step: AIC=4048.08
## ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site +
## Hour + Year + Tot_Knocks:Site + Tot_Knocks:Hour + Num_Herbivory:Site +
## Num_Herbivory:Hour + Num_L_calls:Hour
##
## Df Deviance AIC
## - Tot_Knocks:Hour 3 3.8849 4042.9
## - Tot_Knocks:Site 4 3.9547 4043.7
## - Num_Herbivory:Hour 3 3.9652 4046.1
## - Num_L_calls:Hour 3 3.9659 4046.1
## - Num_Herbivory:Site 4 4.0246 4046.5
## - Year 1 3.8747 4046.5
## <none> 3.8643 4048.1
##
## Step: AIC=4043.1
## ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site +
## Hour + Year + Tot_Knocks:Site + Num_Herbivory:Site + Num_Herbivory:Hour +
## Num_L_calls:Hour
##
## Df Deviance AIC
## - Tot_Knocks:Site 4 3.9597 4038.1
## - Num_Herbivory:Hour 3 3.9721 4040.6
## - Num_L_calls:Hour 3 3.9864 4041.2
## - Num_Herbivory:Site 4 4.0413 4041.4
## - Year 1 3.8959 4041.5
## <none> 3.8849 4043.1
##
## Step: AIC=4038.76
## ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site +
## Hour + Year + Num_Herbivory:Site + Num_Herbivory:Hour + Num_L_calls:Hour
##
## Df Deviance AIC
## - Num_Herbivory:Hour 3 4.0359 4035.9
## - Num_L_calls:Hour 3 4.0467 4036.3
## - Year 1 3.9627 4036.9
## - Num_Herbivory:Site 4 4.1360 4037.9
## - Tot_Knocks 1 3.9995 4038.4
## <none> 3.9597 4038.8
##
## Step: AIC=4036.41
## ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site +
## Hour + Year + Num_Herbivory:Site + Num_L_calls:Hour
##
## Df Deviance AIC
## - Num_L_calls:Hour 3 4.1075 4033.3
## - Year 1 4.0389 4034.5
## - Num_Herbivory:Site 4 4.2302 4036.3
## <none> 4.0359 4036.4
## - Tot_Knocks 1 4.0871 4036.5
##
## Step: AIC=4033.78
## ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site +
## Hour + Year + Num_Herbivory:Site
##
## Df Deviance AIC
## - Hour 3 4.1672 4030.2
## - Year 1 4.1094 4031.9
## - Num_Herbivory:Site 4 4.3010 4033.6
## <none> 4.1075 4033.8
## - Tot_Knocks 1 4.1576 4033.8
## - Num_L_calls 1 4.1776 4034.6
##
## Step: AIC=4030.55
## ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site +
## Year + Num_Herbivory:Site
##
## Df Deviance AIC
## - Year 1 4.1686 4028.6
## - Tot_Knocks 1 4.2086 4030.2
## - Num_L_calls 1 4.2113 4030.3
## <none> 4.1672 4030.5
## - Num_Herbivory:Site 4 4.3652 4030.6
##
## Step: AIC=4028.61
## ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site +
## Num_Herbivory:Site
##
## Df Deviance AIC
## - Tot_Knocks 1 4.2092 4028.3
## - Num_L_calls 1 4.2137 4028.4
## <none> 4.1686 4028.6
## - Num_Herbivory:Site 4 4.3721 4028.9
##
## Step: AIC=4028.47
## ACI_Midrange ~ Num_Herbivory + Num_L_calls + Site + Num_Herbivory:Site
##
## Df Deviance AIC
## - Num_L_calls 1 4.2572 4028.4
## <none> 4.2092 4028.5
## - Num_Herbivory:Site 4 4.4228 4029.2
##
## Step: AIC=4028.64
## ACI_Midrange ~ Num_Herbivory + Site + Num_Herbivory:Site
##
## Call: glm(formula = ACI_Midrange ~ Num_Herbivory + Site + Num_Herbivory:Site,
## family = "Gamma", data = AC.DF1Co)
##
## Coefficients:
## (Intercept) Num_Herbivory Site35
## 1.795e-05 3.282e-07 -1.544e-06
## Site40 Site5 Site8
## 9.005e-07 -1.530e-06 -1.156e-06
## Num_Herbivory:Site35 Num_Herbivory:Site40 Num_Herbivory:Site5
## -2.453e-07 -3.617e-07 -3.830e-07
## Num_Herbivory:Site8
## -3.881e-07
##
## Degrees of Freedom: 190 Total (i.e. Null); 181 Residual
## Null Deviance: 4.987
## Residual Deviance: 4.257 AIC: 4029
AICc(fit.a, ACI.mf.lm)
## df AICc
## fit.a 34 4070.423
## ACI.mf.lm 4 4038.392
Most parsimonious and best model from the AIC stepwise model selection
#ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site + Hour + Year + Num_Herbivory:Site
fit.a2 <- glm(ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls + Site + Hour + Num_Herbivory:Site, data = AC.DF1Co, family = "Gamma")
summary(fit.a2)
##
## Call:
## glm(formula = ACI_Midrange ~ Tot_Knocks + Num_Herbivory + Num_L_calls +
## Site + Hour + Num_Herbivory:Site, family = "Gamma", data = AC.DF1Co)
##
## Deviance Residuals:
## Min 1Q Median 3Q Max
## -0.24565 -0.13928 -0.02445 0.09444 0.38612
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 1.765e-05 1.247e-06 14.159 <2e-16 ***
## Tot_Knocks -5.791e-09 4.065e-09 -1.424 0.1561
## Num_Herbivory 3.515e-07 4.013e-07 0.876 0.3823
## Num_L_calls -5.311e-08 3.028e-08 -1.754 0.0811 .
## Site35 -1.617e-06 1.255e-06 -1.288 0.1993
## Site40 1.023e-06 1.277e-06 0.801 0.4244
## Site5 -1.279e-06 1.285e-06 -0.995 0.3209
## Site8 -1.117e-06 1.241e-06 -0.900 0.3692
## Hour21 6.821e-07 6.162e-07 1.107 0.2699
## Hour3 4.663e-07 6.153e-07 0.758 0.4495
## Hour9 -8.317e-08 6.137e-07 -0.136 0.8924
## Num_Herbivory:Site35 -2.689e-07 4.043e-07 -0.665 0.5069
## Num_Herbivory:Site40 -3.351e-07 4.185e-07 -0.801 0.4244
## Num_Herbivory:Site5 -4.007e-07 4.039e-07 -0.992 0.3225
## Num_Herbivory:Site8 -4.079e-07 4.026e-07 -1.013 0.3123
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## (Dispersion parameter for Gamma family taken to be 0.02451643)
##
## Null deviance: 4.9867 on 190 degrees of freedom
## Residual deviance: 4.1094 on 176 degrees of freedom
## AIC: 4031.9
##
## Number of Fisher Scoring iterations: 4
ggplot(data =Snap.HF, aes(Snap.HF$ACI_HF)) + geom_histogram() + ggtitle("HF ACI distribution") + geom_vline(aes(xintercept = mean(ACI_HF)), color = "red", linetype ="dashed", size = 1) + geom_vline(aes(xintercept = median(ACI_HF)), color = "blue", linetype = "dotted", size = 1)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Distribution looks normal, given what we discussed about the HF SPL distribution
#testing time splits for this model to confirm they are the same as SPL HF model
afit.tg <- lm(ACI_HF ~ Snaps*tg*Site + Year, data = Snap.HFC)
afit.dn <- lm(ACI_HF ~ Snaps*dn*Site + Year, data = Snap.HFC)
afit.ns <- lm(ACI_HF ~ Snaps*ns*Site + Year, data = Snap.HFC)
afit.t12 <- lm(ACI_HF ~Snaps*t12*Site + Year, data = Snap.HFC)
AICc(afit.tg, afit.dn, afit.ns, afit.t12)
## df AICc
## afit.tg 42 318203.3
## afit.dn 22 318276.9
## afit.ns 32 318292.4
## afit.t12 22 318159.7
fit.hfaci <- lm(ACI_HF ~ Snaps*t12 + Snaps*Site + t12*Site + Year, data = Snap.HFC)
fit.hfaci2 <- lm(ACI_HF ~ Snaps*t12*Site + Year, data = Snap.HFC)
fit.hfaci3 <- lm(ACI_HF ~ Snaps*t12 + Snaps*Site + Year, data = Snap.HFC)
AICc(fit.hfaci,fit.hfaci2, fit.hfaci3)
## df AICc
## fit.hfaci 18 318164.8
## fit.hfaci2 22 318159.7
## fit.hfaci3 14 318393.5
summary(fit.hfaci2)
##
## Call:
## lm(formula = ACI_HF ~ Snaps * t12 * Site + Year, data = Snap.HFC)
##
## Residuals:
## Min 1Q Median 3Q Max
## -12613.4 -3641.7 -958.7 2729.3 21530.1
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -2.883e+05 1.821e+05 -1.583 0.11351
## Snaps -5.588e+00 2.739e+00 -2.040 0.04135 *
## t12Low -1.203e+03 1.866e+02 -6.445 1.19e-10 ***
## Site35 4.440e+03 2.333e+02 19.033 < 2e-16 ***
## Site40 3.104e+01 2.469e+02 0.126 0.89996
## Site5 4.635e+02 1.972e+02 2.350 0.01880 *
## Site8 3.123e+03 1.827e+02 17.096 < 2e-16 ***
## Year 1.739e+02 9.029e+01 1.927 0.05406 .
## Snaps:t12Low 8.336e+00 3.251e+00 2.564 0.01034 *
## Snaps:Site35 9.194e-01 4.078e+00 0.225 0.82164
## Snaps:Site40 -7.411e+00 4.369e+00 -1.696 0.08987 .
## Snaps:Site5 1.576e+00 4.318e+00 0.365 0.71516
## Snaps:Site8 -1.934e+01 3.950e+00 -4.896 9.85e-07 ***
## t12Low:Site35 5.579e+02 3.166e+02 1.762 0.07806 .
## t12Low:Site40 2.276e+02 3.241e+02 0.702 0.48259
## t12Low:Site5 3.701e+03 2.738e+02 13.519 < 2e-16 ***
## t12Low:Site8 -4.602e+02 3.445e+02 -1.336 0.18169
## Snaps:t12Low:Site35 -6.317e+00 5.227e+00 -1.209 0.22683
## Snaps:t12Low:Site40 -9.996e+00 5.456e+00 -1.832 0.06693 .
## Snaps:t12Low:Site5 -1.329e+01 5.584e+00 -2.380 0.01733 *
## Snaps:t12Low:Site8 -1.707e+01 5.080e+00 -3.360 0.00078 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 5069 on 15966 degrees of freedom
## Multiple R-squared: 0.1587, Adjusted R-squared: 0.1577
## F-statistic: 150.6 on 20 and 15966 DF, p-value: < 2.2e-16
stepAIC(fit.hfaci2)
## Start: AIC=272788.5
## ACI_HF ~ Snaps * t12 * Site + Year
##
## Df Sum of Sq RSS AIC
## <none> 4.1026e+11 272788
## - Year 1 95367893 4.1035e+11 272790
## - Snaps:t12:Site 4 338278009 4.1059e+11 272794
##
## Call:
## lm(formula = ACI_HF ~ Snaps * t12 * Site + Year, data = Snap.HFC)
##
## Coefficients:
## (Intercept) Snaps t12Low
## -2.883e+05 -5.587e+00 -1.203e+03
## Site35 Site40 Site5
## 4.440e+03 3.104e+01 4.635e+02
## Site8 Year Snaps:t12Low
## 3.123e+03 1.739e+02 8.336e+00
## Snaps:Site35 Snaps:Site40 Snaps:Site5
## 9.194e-01 -7.411e+00 1.576e+00
## Snaps:Site8 t12Low:Site35 t12Low:Site40
## -1.934e+01 5.579e+02 2.276e+02
## t12Low:Site5 t12Low:Site8 Snaps:t12Low:Site35
## 3.701e+03 -4.602e+02 -6.317e+00
## Snaps:t12Low:Site40 Snaps:t12Low:Site5 Snaps:t12Low:Site8
## -9.996e+00 -1.329e+01 -1.707e+01
IP4 <- interaction.plot(Snap.HFC$t12, Snap.HFC$Site, Snap.HF$ACI_HF)
So it looks like ACI has a significant 3 way interaction at site 5… WHAT DOES THIS MEAN AND HOW DO I SHOW IT
Show it - I think I can make a 2 frame plot, facet_wrap by time, showing the effect between Snaps and ACI in each plot
What does it mean - it means that HF ACI is significantly associated with combined changes of Snaps and Time and Site (but only at site 5?)
#fit.hfaci <- lm(ACI_HF ~(Snaps*t12*Site) + Year, data = Snap.HF)
#summary(fit.hfaci)
#stepAIC(fit.a)
#AICc(fit.a, ACI.mf.lm)
Determining which is the best way to group the snaps by time
tg = quarters (00-05, 06-11, 12-17, 18-23) dn = day night (18-05, 6-17) ns = nine cycle (22-03, 04-09, 10-15, 16-21) t12 = my half and half cycle (2140 - 920, 920 - 2140)
fit.tg <- lm(SPL_HF ~ Snaps*tg*Site + Year, data = Snap.HFC)
fit.dn <- lm(SPL_HF ~ Snaps*dn*Site + Year, data = Snap.HFC)
fit.ns <- lm(SPL_HF ~ Snaps*ns*Site + Year, data = Snap.HFC)
fit.t12 <- lm(SPL_HF ~Snaps*t12*Site + Year, data = Snap.HFC)
#models that have a 2 way interaction and time seperately as a factor
fit.t12t <- lm(SPL_HF ~ Snaps*Site + t12 + Year, data = Snap.HFC)
fit.tgt <- lm(SPL_HF ~ Snaps*Site + tg + Year, data = Snap.HFC)
fit.dnt <- lm(SPL_HF ~ Snaps*Site + dn + Year, data = Snap.HFC)
fit.nst <- lm(SPL_HF ~ Snaps*Site + ns + Year, data = Snap.HFC)
AICc(fit.tg, fit.dn, fit.ns, fit.t12, fit.t12t, fit.tgt, fit.dnt, fit.nst)
## df AICc
## fit.tg 42 68564.26
## fit.dn 22 72450.05
## fit.ns 32 70408.03
## fit.t12 22 64311.29
## fit.t12t 13 65331.35
## fit.tgt 15 70314.51
## fit.dnt 13 72650.42
## fit.nst 14 71856.06
Best model was the one that split time at 9:20 and 21:40
Confused about my next steps here
stepAIC(fit.t12)
## Start: AIC=18940.08
## SPL_HF ~ Snaps * t12 * Site + Year
##
## Df Sum of Sq RSS AIC
## <none> 52137 18940
## - Snaps:t12:Site 4 1087 53223 19262
## - Year 1 35884 88021 27311
##
## Call:
## lm(formula = SPL_HF ~ Snaps * t12 * Site + Year, data = Snap.HFC)
##
## Coefficients:
## (Intercept) Snaps t12Low
## -6.687e+03 -8.989e-03 -2.886e+00
## Site35 Site40 Site5
## -1.421e+00 -1.297e+00 -1.782e+00
## Site8 Year Snaps:t12Low
## 1.615e+00 3.374e+00 5.547e-03
## Snaps:Site35 Snaps:Site40 Snaps:Site5
## 3.703e-02 1.997e-02 8.580e-03
## Snaps:Site8 t12Low:Site35 t12Low:Site40
## 5.426e-03 -7.920e-02 -8.341e-01
## t12Low:Site5 t12Low:Site8 Snaps:t12Low:Site35
## -1.815e+00 -2.476e+00 -3.223e-02
## Snaps:t12Low:Site40 Snaps:t12Low:Site5 Snaps:t12Low:Site8
## -7.714e-03 -2.101e-03 -9.700e-03
#returned only the three way interaction - so I am going to try some manual selection to see if there is a more parsimonious model
fit.hf1 <- lm(SPL_HF ~ Snaps + t12 + Site + Snaps:t12 + Snaps:Site + t12:Site, data = Snap.HFC)
fit.hf2 <- lm(SPL_HF ~ Snaps + t12 + Site + Snaps:t12 + Snaps:Site, data = Snap.HFC)
fit.hf3 <- lm(SPL_HF ~ Snaps + Site + Snaps:Site, data = Snap.HFC)
AICc(fit.t12,fit.hf1, fit.hf2, fit.hf3)
## df AICc
## fit.t12 22 64311.29
## fit.hf1 17 73122.38
## fit.hf2 13 73615.19
## fit.hf3 11 78480.77
#SPL_HF ~ Snaps + t12 + Site + Snaps:t12 + Snaps:Site + t12:Site
snap.model <- lm(SPL_HF ~ Snaps + t12 + Site + Snaps:t12 + Snaps:Site + t12:Site, data = Snap.HFC)
Anova(fit.t12, type = 3)
## Anova Table (Type III tests)
##
## Response: SPL_HF
## Sum Sq Df F value Pr(>F)
## (Intercept) 34636 1 10606.698 < 2.2e-16 ***
## Snaps 277 1 84.770 < 2.2e-16 ***
## t12 6147 1 1882.447 < 2.2e-16 ***
## Site 9383 4 718.363 < 2.2e-16 ***
## Year 35884 1 10989.000 < 2.2e-16 ***
## Snaps:t12 75 1 22.915 1.709e-06 ***
## Snaps:Site 2628 4 201.172 < 2.2e-16 ***
## t12:Site 2166 4 165.863 < 2.2e-16 ***
## Snaps:t12:Site 1087 4 83.194 < 2.2e-16 ***
## Residuals 52137 15966
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
summary(fit.t12)
##
## Call:
## lm(formula = SPL_HF ~ Snaps * t12 * Site + Year, data = Snap.HFC)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.0059 -1.1523 -0.0511 1.0325 9.5333
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) -6.687e+03 6.493e+01 -102.989 < 2e-16 ***
## Snaps -8.989e-03 9.763e-04 -9.207 < 2e-16 ***
## t12Low -2.886e+00 6.652e-02 -43.387 < 2e-16 ***
## Site35 -1.421e+00 8.317e-02 -17.087 < 2e-16 ***
## Site40 -1.297e+00 8.802e-02 -14.738 < 2e-16 ***
## Site5 -1.782e+00 7.031e-02 -25.344 < 2e-16 ***
## Site8 1.615e+00 6.512e-02 24.808 < 2e-16 ***
## Year 3.374e+00 3.219e-02 104.828 < 2e-16 ***
## Snaps:t12Low 5.547e-03 1.159e-03 4.787 1.71e-06 ***
## Snaps:Site35 3.703e-02 1.454e-03 25.471 < 2e-16 ***
## Snaps:Site40 1.997e-02 1.558e-03 12.819 < 2e-16 ***
## Snaps:Site5 8.580e-03 1.539e-03 5.574 2.52e-08 ***
## Snaps:Site8 5.426e-03 1.408e-03 3.853 0.000117 ***
## t12Low:Site35 -7.920e-02 1.129e-01 -0.702 0.482821
## t12Low:Site40 -8.341e-01 1.155e-01 -7.219 5.49e-13 ***
## t12Low:Site5 -1.815e+00 9.759e-02 -18.596 < 2e-16 ***
## t12Low:Site8 -2.476e+00 1.228e-01 -20.156 < 2e-16 ***
## Snaps:t12Low:Site35 -3.223e-02 1.863e-03 -17.297 < 2e-16 ***
## Snaps:t12Low:Site40 -7.714e-03 1.945e-03 -3.967 7.32e-05 ***
## Snaps:t12Low:Site5 -2.101e-03 1.991e-03 -1.056 0.291199
## Snaps:t12Low:Site8 -9.700e-03 1.811e-03 -5.357 8.59e-08 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 1.807 on 15966 degrees of freedom
## Multiple R-squared: 0.7323, Adjusted R-squared: 0.7319
## F-statistic: 2183 on 20 and 15966 DF, p-value: < 2.2e-16
plot(fit.t12)
hist(resid(snap.model))
## NULL
## NULL
## NULL
Plots for use in paper
This first plot uses ALL data (2017 & 2018) and all sites
It seems super crowded, so maybe we only need to display a piece of it?
Here is a plot using only one site (Site 5)
This plot uses ALL data (2017 & 2018) and all sites/hours
Way too much going on.
Here is a plot that only uses 9am
This shows that the pattern exists at pretty much all sites except for 5. I think this is the plot to go with.
That looks nice!
Hey! So does that! Is it not OK for us to use site 5 here because it was the one site that didn’t seem to have a strong relationship at 9 AM?
## [1] "21:00" "21:10" "21:20" "21:30" "21:40" "21:50" "22:00" "22:10"
## [9] "22:20" "22:30" "22:40" "22:50" "23:00" "23:10" "23:20" "23:30"
## [17] "23:40" "23:50" "0:00" "0:10" "0:20" "0:30" "0:40" "0:50"
## [25] "1:00" "1:10" "1:20" "1:30" "1:40" "1:50" "2:00" "2:10"
## [33] "2:20" "2:30" "2:40" "2:50" "3:00" "3:10" "3:20" "3:30"
## [41] "3:40" "3:50" "4:00" "4:10" "4:20" "4:30" "4:40" "4:50"
## [49] "5:00" "5:10" "5:20" "5:30" "5:40" "5:50" "6:00" "6:10"
## [57] "6:20" "6:30" "6:40" "6:50" "7:00" "7:10" "7:20" "7:30"
## [65] "7:40" "7:50" "8:00" "8:10" "8:20" "8:30" "8:40" "8:50"
## [73] "9:00" "9:10" "9:20" "9:30" "9:40" "9:50" "10:00" "10:10"
## [81] "10:20" "10:30" "10:40" "10:50" "11:00" "11:10" "11:20" "11:30"
## [89] "11:40" "11:50" "12:00" "12:10" "12:20" "12:30" "12:40" "12:50"
## [97] "13:00" "13:10" "13:20" "13:30" "13:40" "13:50" "14:00" "14:10"
## [105] "14:20" "14:30" "14:40" "14:50" "15:00" "15:10" "15:20" "15:30"
## [113] "15:40" "15:50" "16:00" "16:10" "16:20" "16:30" "16:40" "16:50"
## [121] "17:00" "17:10" "17:20" "17:30" "17:40" "17:50" "18:00" "18:10"
## [129] "18:20" "18:30" "18:40" "18:50" "19:00" "19:10" "19:20" "19:30"
## [137] "19:40" "19:50" "20:00" "20:10" "20:20" "20:30" "20:40" "20:50"
## [145] "11:45" "12:15" "12:45" "13:15" "13:45" "14:15" "14:45" "15:15"
## [153] "15:45" "16:15" "16:45" "17:15" "17:45" "18:15" "18:45" "19:15"
## [161] "19:45" "20:15" "20:45" "21:15" "21:45" "22:15" "22:45" "23:15"
## [169] "23:45" "0:15" "0:45" "1:15" "1:45" "2:15" "2:45" "3:15"
## [177] "3:45" "4:15" "4:45" "5:15" "5:45" "6:15" "6:45" "7:15"
## [185] "7:45" "8:15" "8:45" "9:15" "9:45" "10:15" "10:45" "11:15"
## [1] "21:00" "21:10" "21:20" "21:30" "21:40" "21:50" "22:00" "22:10"
## [9] "22:20" "22:30" "22:40" "22:50" "23:00" "23:10" "23:20" "23:30"
## [17] "23:40" "23:50" "0:00" "0:10" "0:20" "0:30" "0:40" "0:50"
## [25] "1:00" "1:10" "1:20" "1:30" "1:40" "1:50" "2:00" "2:10"
## [33] "2:20" "2:30" "2:40" "2:50" "3:00" "3:10" "3:20" "3:30"
## [41] "3:40" "3:50" "4:00" "4:10" "4:20" "4:30" "4:40" "4:50"
## [49] "5:00" "5:10" "5:20" "5:30" "5:40" "5:50" "6:00" "6:10"
## [57] "6:20" "6:30" "6:40" "6:50" "7:00" "7:10" "7:20" "7:30"
## [65] "7:40" "7:50" "8:00" "8:10" "8:20" "8:30" "8:40" "8:50"
## [73] "9:00" "9:10" "9:20" "9:30" "9:40" "9:50" "10:00" "10:10"
## [81] "10:20" "10:30" "10:40" "10:50" "11:00" "11:10" "11:20" "11:30"
## [89] "11:40" "11:50" "12:00" "12:10" "12:20" "12:30" "12:40" "12:50"
## [97] "13:00" "13:10" "13:20" "13:30" "13:40" "13:50" "14:00" "14:10"
## [105] "14:20" "14:30" "14:40" "14:50" "15:00" "15:10" "15:20" "15:30"
## [113] "15:40" "15:50" "16:00" "16:10" "16:20" "16:30" "16:40" "16:50"
## [121] "17:00" "17:10" "17:20" "17:30" "17:40" "17:50" "18:00" "18:10"
## [129] "18:20" "18:30" "18:40" "18:50" "19:00" "19:10" "19:20" "19:30"
## [137] "19:40" "19:50" "20:00" "20:10" "20:20" "20:30" "20:40" "20:50"
## [145] "11:45" "12:15" "12:45" "13:15" "13:45" "14:15" "14:45" "15:15"
## [153] "15:45" "16:15" "16:45" "17:15" "17:45" "18:15" "18:45" "19:15"
## [161] "19:45" "20:15" "20:45" "21:15" "21:45" "22:15" "22:45" "23:15"
## [169] "23:45" "0:15" "0:45" "1:15" "1:45" "2:15" "2:45" "3:15"
## [177] "3:45" "4:15" "4:45" "5:15" "5:45" "6:15" "6:45" "7:15"
## [185] "7:45" "8:15" "8:45" "9:15" "9:45" "10:15" "10:45" "11:15"
## [1] "21:00" "21:10" "21:20" "21:30" "21:40" "21:50" "22:00" "22:10"
## [9] "22:20" "22:30" "22:40" "22:50" "23:00" "23:10" "23:20" "23:30"
## [17] "23:40" "23:50" "0:00" "0:10" "0:20" "0:30" "0:40" "0:50"
## [25] "1:00" "1:10" "1:20" "1:30" "1:40" "1:50" "2:00" "2:10"
## [33] "2:20" "2:30" "2:40" "2:50" "3:00" "3:10" "3:20" "3:30"
## [41] "3:40" "3:50" "4:00" "4:10" "4:20" "4:30" "4:40" "4:50"
## [49] "5:00" "5:10" "5:20" "5:30" "5:40" "5:50" "6:00" "6:10"
## [57] "6:20" "6:30" "6:40" "6:50" "7:00" "7:10" "7:20" "7:30"
## [65] "7:40" "7:50" "8:00" "8:10" "8:20" "8:30" "8:40" "8:50"
## [73] "9:00" "9:10" "9:20" "9:30" "9:40" "9:50" "10:00" "10:10"
## [81] "10:20" "10:30" "10:40" "10:50" "11:00" "11:10" "11:20" "11:30"
## [89] "11:40" "11:50" "12:00" "12:10" "12:20" "12:30" "12:40" "12:50"
## [97] "13:00" "13:10" "13:20" "13:30" "13:40" "13:50" "14:00" "14:10"
## [105] "14:20" "14:30" "14:40" "14:50" "15:00" "15:10" "15:20" "15:30"
## [113] "15:40" "15:50" "16:00" "16:10" "16:20" "16:30" "16:40" "16:50"
## [121] "17:00" "17:10" "17:20" "17:30" "17:40" "17:50" "18:00" "18:10"
## [129] "18:20" "18:30" "18:40" "18:50" "19:00" "19:10" "19:20" "19:30"
## [137] "19:40" "19:50" "20:00" "20:10" "20:20" "20:30" "20:40" "20:50"
## [145] "11:45" "12:15" "12:45" "13:15" "13:45" "14:15" "14:45" "15:15"
## [153] "15:45" "16:15" "16:45" "17:15" "17:45" "18:15" "18:45" "19:15"
## [161] "19:45" "20:15" "20:45" "21:15" "21:45" "22:15" "22:45" "23:15"
## [169] "23:45" "0:15" "0:45" "1:15" "1:45" "2:15" "2:45" "3:15"
## [177] "3:45" "4:15" "4:45" "5:15" "5:45" "6:15" "6:45" "7:15"
## [185] "7:45" "8:15" "8:45" "9:15" "9:45" "10:15" "10:45" "11:15"